home *** CD-ROM | disk | FTP | other *** search
- vs.1.1
-
- ;Vertex packing
- dcl_position v0
- dcl_blendweight v1
- dcl_blendindices v2
- dcl_normal v3
- dcl_binormal v4
- dcl_tangent v5
- dcl_texcoord0 v7
-
- ;Constant map from the NSF.
- ;CM_Defined SkinWorldViewProjTranspose 0 0
- ;CM_Constant const_1_1_1_255 4 1 1.0,1.0,1.0,765.01
- ;CM_Constant Half 5 1 0.5,0.5,0.5,0.5
- ;CM_Constant Zero 6 1 0.0,0.0,0.0,0.0
- ;CM_Defined WorldViewTranspose 7 4
- ;CM_Defined BoneMatrix3 11 0 28
-
- ;Determine the 4th weight. We only pack 3, and this insures that the weights
- ;sum to 1. We'll keep weights in r0.
- mov r0.xyz, v1.xyz ; r0.xyz = w0,w1,w2
- dp3 r0.w, v1.xyz, c4.xxxx ; r0.w = w0 + w1 + w2
- add r0.w, -r0.w, c4.x ; r0.2 = 1 - (w0 + w1 + w2) = w3
-
- ;Need to offset the values. The indices are packed as floats from 0 to 1, but
- ;they are originally packed as bytes. Since each bone matrix in this shader
- ;takes 3 constant registers, we scale each float by 765.01 to make it equal
- ;the original byte value times 3. The .01 insures that any floating point
- ;rounding does not bias our results incorrectly downward.
- mul r1, v2.zyxw, c4.wwww ; r1 = indices w/ offset (D3DCOLOR Version)
-
- ;We now have the weights in r0 and the indices in r1. We will move each
- ;index into a0.x and blend a matrix together with the weights. The registers
- ;r2, r3, and r4 will hold this final 3x4 matrix which we will use to transform
- ;points into world space as well as normals. The points will end up in world
- ;space because each BoneMatrix3 represents a transform from bind pose skin
- ;space to bone space and the current transform from bone space to world space.
-
- ;First bone
- mov a0.x, r1.x
- mul r2, r0.x, c[a0.x+0+11] ;8
- mul r3, r0.x, c[a0.x+1+11]
- mul r4, r0.x, c[a0.x+2+11]
-
- ;Second bone
- mov a0.x, r1.y
- mad r2, r0.y, c[a0.x+0+11], r2
- mad r3, r0.y, c[a0.x+1+11], r3
- mad r4, r0.y, c[a0.x+2+11], r4
-
- ;Third bone
- mov a0.x, r1.z
- mad r2, r0.z, c[a0.x+0+11], r2
- mad r3, r0.z, c[a0.x+1+11], r3
- mad r4, r0.z, c[a0.x+2+11], r4
-
- ;Fourth bone
- mov a0.x, r1.w
- mad r2, r0.w, c[a0.x+0+11], r2
- mad r3, r0.w, c[a0.x+1+11], r3
- mad r4, r0.w, c[a0.x+2+11], r4
-
- ;The vertex will now be deformed into world space with the blended matrix in
- ;r2, r3, and r4.
- dp4 r5.x, v0, r2
- dp4 r5.y, v0, r3
- dp4 r5.z, v0, r4
- mov r5.w, c4.x
-
- ;Transform normal to worldspace
- dp3 r11.x, v3, r2
- dp3 r11.y, v3, r3
- dp3 r11.z, v3, r4
- mov r11.w, c6.x
-
- ;Transform normal to viewspace
- m4x4 r10, r11, c6
-
- ; Shouldn't be necessary to normalize normal since we hopefully got an orthogonal transform and unit source normals
-
- ;Expand normal to texture coords (N * 0.5f + 0.5f)
- mad r10, r10, c5, c5
-
- ;Calculate environment texture coords from worldspace normal
- mov oT0.xy, r10.xy
-
- ;Transform position to clip space
- m4x4 oPos, r5, c0